#include <cstdlib>
#include <iterator>
#include <vector>
#include <iostream>
#include <algorithm>
#include "bank_balance.hpp"

int random_number()
{
    return rand() % 255;
}

void print_balances(const std::vector<bank::bank_balance>& array) {
    std::copy(array.begin(), array.end(), std::ostream_iterator<bank::bank_balance>(std::cout, " "));
    std::cout << "\n";
}

int main(int argc, char* argv[])
{
    srand(time(0));
    
    std::vector<bank::bank_balance> array(4);
    std::vector<std::vector<bank::bank_balance>> permutations;

    // Fill the accounts with balances
    std::generate(array.begin(), array.end(), random_number);

    // Print the balances
    std::cout << "contents of balances:";
    print_balances(array);


    // Calculate permutations
    std::sort(array.begin(), array.end());
    permutations.push_back(array);
    while(next_permutation(array.begin(), array.end())) {
        permutations.push_back(array);
    }

    // Print permutations
    std::cout << "Permutations:";
    for_each(permutations.begin(), permutations.end(), print_balances);
    
    return 0;
}

